var u = navigator.userAgent;

var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isIos = u.indexOf("Mac OS X") > -1;     //判断是否是 iOS终端
